<?php 
defined('RUN_KATANA') or die('Restricted access');
$zones = $shop->getShippingZones();
$setFavStore = 0;
if(intval($_REQUEST['fav_store']) > 0)
{ $setFavStore = intval($_GET['fav_store']); }
?>
<div class="visible-md visible-lg">
	<h3 class="nav-header">Din favoritt butikk</h3>
	<ul class="nav nav-pills nav-stacked">
	  <li class="dropdown">
		<?php 
		$out = '';
		if($zones)
		{
			$selected = '';
			foreach($zones as $zone)
			{
				if($zone['parent_id'] == 3)
				{
					if((isset($_COOKIE['fav_store'])) || ($setFavStore > 0))
					{
						if($setFavStore > 0)
						{
							if($setFavStore == $zone['id'])
							{ $selected = str_replace('Baker Hansen ', '', $zone['title']); }
						}
						else
						{
							if(intval($_COOKIE['fav_store']) == $zone['id'])
							{ $selected = str_replace('Baker Hansen ', '', $zone['title']); }
						}
						
					}
					$out .= '<li>';
					$out .= '<a href="?fav_store='.$zone['id'].'">';
					$out .= $zone['title'];
					$out .= '</a>';
					$out .= '</li>';
				}
			}
		}
		?>
		<?php if($selected): ?>
		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo $selected; ?> <b class="caret"></b></a>
		<?php else: ?>
		<a href="#" class="dropdown-toggle" data-toggle="dropdown">Velg din favoritt butikk <b class="caret"></b></a>
		<?php endif; ?>
		<ul class="dropdown-menu">
			<?php echo $out; ?>
			<li class="divider"></li>
		</ul>
	  </li>
	</ul>
</div>
<?php /* <form action="<?php echo $katana->getFormAction(); ?>" method="post" enctype="multipart/form-data" name="fav_store">
    <div class="form-group">
    	<label for="fav_store">Din favoritt butikk</label>
        <select name="fav_store" class="form-control" onchange="submit();">
            <option>Velg din favoritt butikk</option>
            <?php 
            if($zones)
            {
                foreach($zones as $zone)
                {
                    $selected = '';
                    if($zone['parent_id'] == 3)
                    {
                        if((isset($_COOKIE['fav_store'])) || (intval($_REQUEST['fav_store']) > 0))
                        {
                            if(intval($_REQUEST['fav_store']) > 0)
                            {
                                if(intval($_REQUEST['fav_store']) == $zone['id'])
                                { $selected = 'selected="selected"'; }
                            }
                            else
                            {
                                if(intval($_COOKIE['fav_store']) == $zone['id'])
                                { $selected = 'selected="selected"'; }
                            }
                            
                        }
                    ?>
                    <option value="<?php echo $zone['id'] ?>" <?php echo $selected; ?>><?php echo str_replace('Baker Hansen Bogstadveien', 'Bogstadveien', $zone['title']); ?></option>
                    <?php 
                    }
                }
            }
            ?>
        </select>
    </div>
</form> */?>